package com.imay.live.view.custom;

import android.content.Context;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.TextView;

import com.imay.live.R;
import com.imay.live.model.TopicModel;

/**
 * Created by jeaman on 2017/6/22.
 * 超短播开播view
 */

public class StartLiveShortView extends StartLiveView {


    public static final int STATUS_LOADING = 1;
    public static final int STATUS_COMPLETE = 2;


    public StartLiveShortView(Context context) {
        super(context);
    }

    public StartLiveShortView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public StartLiveShortView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public StartLiveShortView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.view_start_live_short;
    }

    protected void init(Context context) {
        super.init(context);
        setBGMViewVisible(true);
    }


    public void setViewByType(TopicModel model){
        if (model!=null){
            findViewById(R.id.ll_room_push_challenge_start).setVisibility(VISIBLE);
            findViewById(R.id.room_short_tv_content_start).setVisibility(VISIBLE);
            findViewById(R.id.tv_room_short_push_tips_start).setVisibility(GONE);
            findViewById(R.id.tv_room_short_push_content_start).setVisibility(GONE);
            ((TextView)findViewById(R.id.tv_room_short_title_start)).setText(model.getTitle());
            ((TextView)findViewById(R.id.room_short_tv_content_start)).setText(model.getContent());

        }else{
            findViewById(R.id.ll_room_push_challenge_start).setVisibility(GONE);
            findViewById(R.id.room_short_tv_content_start).setVisibility(GONE);
            findViewById(R.id.tv_room_short_push_tips_start).setVisibility(VISIBLE);
            findViewById(R.id.tv_room_short_push_content_start).setVisibility(VISIBLE);
        }

    }


    public void setButtonStatus(int status){
        if (status == STATUS_LOADING){
            mStartBtn.setText(R.string.loading);
            mStartBtn.setEnabled(false);
        }else{
            mStartBtn.setText(R.string.short_live_push_start);
            mStartBtn.setEnabled(true);
        }

    }

}
